﻿
using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 图像跟随算法
    /// </summary>
    [Filter("图像跟踪",FilterType.Algorithm)]
    public class AlgorithmCamShift : FilterBase
    {
        /// <summary>
        /// 要跟踪的区域
        /// </summary>
        [InputParameter("要跟踪的区域")]
        public Rect Rect { get; set; }
        /// <summary>
        /// 交互算法
        /// </summary>
        [InputParameter("交互算法")]
        public TermCriteria TermCriteria { get; set; }
        /// <summary>
        /// 跟踪结果
        /// </summary>
        [OutputParameter("跟踪结果")]
        public RotatedRect RotatedRect { get; set; }
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Rect rect= Rect;
            RotatedRect= Cv2.CamShift(mat, ref rect, TermCriteria);
            Rect = rect;
          return  ResultData<Mat>.Accept(TextResource.camshift_success,mat);
        }
    }
}
